<script>
import outMain from "@/components/outMain.vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { RenewRecord } from "@/http/api";

export default {
  components: { outMain },
  name: "",
  data() {
    return {
      tableData: [],
      queryData: {
        order_number: "",
        page: 1,
        per_page: 10,
      },
      total: 0,
    };
  },
  props: {},
  setup() {},
  methods: {
    getData() {
      RenewRecord(this.queryData).then((res) => {
        if (res.data.code == 1) {
          this.tableData = res.data.data.data;
          this.total = res.data.data.total;
        }
      });
    },
    detailFn(item) {
      let path = "";
      if (item.terminal_type == 1 || item.terminal_type == 4) {
        path = "/accountCompanyDetail";
      } else if (item.terminal_type == 2) {
        path = "/accountTrainDetail";
      } else if (item.terminal_type == 3) {
        path = "/booterListDetail";
      }
      this.$router.push({
        path: path,
        query: { id: item.account_id, page: this.queryData.page },
      });
    },
  },
  mounted() {},
  created() {
    this.queryData.page = Number(localStorage.getItem("boot_page")) || 1;

    this.getData();
  },
};
</script>
<template>
  <outMain>
    <div class="tableCont">
      <div class="tableName flexCont">
        <div>账号续费记录（{{ total }}）</div>
      </div>
      <div class="tableSerch">
        <div class="serchLeft"></div>
        <div class="serchRight">
          <el-form class="flexCenter" :inline="true">
            <el-form-item>
              <el-input
                clearable
                @clear="getData"
                @keyup.enter="getData"
                v-model="queryData.order_number"
                placeholder="请输入续费单号"
              />
            </el-form-item>
            <btn value="搜索" @click="getData"></btn>
          </el-form>
        </div>
      </div>
      <el-table class="tableMain" :data="tableData" stripe style="width: 100%">
        <el-table-column
          prop="order_number"
          width="250"
          show-overflow-tooltip
          label="续费单号"
        />
        <el-table-column
          width="250"
          prop="account_name"
          show-overflow-tooltip
          label="续费账号"
        />
        <el-table-column
          width="120"
          prop="payType"
          show-overflow-tooltip
          label="账号类型"
        >
          <template #default="{ row }">
            <span v-if="row.terminal_type == 1">企业账号</span>
            <span v-if="row.terminal_type == 2">培训账号</span>
            <span v-if="row.terminal_type == 3">船东账号</span>
            <span v-if="row.terminal_type == 4">员工账号</span>
          </template>
        </el-table-column>
        <el-table-column
          width="120"
          prop="coin"
          show-overflow-tooltip
          label="续费鲸币"
        />
        <el-table-column
          width="120"
          prop="creatTime"
          show-overflow-tooltip
          label="续费时间"
        >
          <template #default="{ row }">
            <span>{{ row.year_sum }}年</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="create_time"
          show-overflow-tooltip
          label="创建时间"
        />
        <el-table-column prop="Name" width="80" label="操作">
          <template #default="{ row }">
            <div class="tableCtrl">
              <div class="blueText ctrlText" @click="detailFn(row)">详情</div>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pageCont">
        <el-pagination
          v-model:currentPage="queryData.page"
          v-model:page-size="queryData.per_page"
          background
          layout="total, prev, pager, next, jumper"
          :total="total"
          @size-change="getData"
          @current-change="getData"
        />
      </div>
    </div>
  </outMain>
</template>
<style scoped lang="less"></style>
